﻿
           @model Everynet.Models.SummaryModel
@{
    ViewBag.Title = "DetailOrders";
    Layout = "~/Views/Shared/_AdminLayout.cshtml";
}
<h2>
    Detail Orders</h2>
    <table width="60%">
    <tr>
    <td style="width:20%;"> @Html.ActionLink("Dashboard", "Dashboard", "Admin")</td>
    <td> @Html.ActionLink("Orders", "Orders", "Admin")</td>
    </tr>
    </table>
    <br />
    <b><u>USER DETAIL:</u></b>
    <br />    <br />

    <table width="70%" border="0">
        <tr>
            <td style="width:20%;background-color:#F3F3F3;">
               ID:
            </td>
            <td style="width:30%;background-color:#DDDDDD;">
                <b> @Html.DisplayFor(model => model.ID)</b>
            </td>

            <td style="width:20%;background-color:#F3F3F3;">
               Plan Name:
            </td>
            <td style="width:30%;background-color:#DDDDDD;">
                <b>@Html.DisplayFor(model => model.Name)</b>
            </td>
        </tr>
        <tr>
            
        </tr>
        
         <tr>
            <td  style="background-color:#F3F3F3;">
               Service Phone:
            </td>
            <td style="background-color:#DDDDDD;">
               <b>@Html.DisplayFor(model => model.ServicePhoneNumber)</b>
            </td>
             <td style="background-color:#F3F3F3;">
               Plan Detail Name:
            </td>
            <td  style="background-color:#DDDDDD;">
                <b>@Html.DisplayFor(model => model.PlanDetailName)</b>
            </td>
        </tr>
  </table>


 <br /> <br /> <br />
    <b><u>ORDER DETAIL:</u></b>
    <br />
    <div>
     <br />
    <table class="tblOrderSummary Header">
        <tr>
            <td width="55%">
                Product Summary
            </td>
            <td width="15%">
                Setup Fee
            </td>
            <td width="15%">
                Per Month
            </td>
            <td width="15%">
                Total Cost
            </td>
        </tr>
    </table>
    <br />
    @if(Model!=null)
    {
    <table class="tblOrderSummary">
        <tr>
            <td width="55%">
                <b>@Model.Name on @Model.ServicePhoneNumber</b>
                <br />
                <br />
                <b>@Model.PlanDetailName</b> <span class="fnt12left">plan</span>
                <br />
                <span class="fnt12left">on a</span> <b>@Model.PlanQuotaValue @Model.PlanQuotaInterval</b>
                <span class="fnt12left">contract</span>
            </td>
            <td width="15%">
                $@Model.SetupCost
                <br />
                <span class="fnt12left">setup</span>
            </td>
            <td width="15%">
              $<span class="calculateMonthTotal">@Model.Price</span> 
                <br />
                <span class="fnt12left">per month</span>
            </td>
            <td width="15%">
                <span class="fnt12left">from</span>
                <br />
                <b>$</b><b class="calculateGrandTotal">@Model.TotalCost</b>
                <br />
                <span class="fnt12left">over @Model.PlanQuotaValue</span>
                <br />
                <span class="fnt12left">@Model.PlanQuotaInterval</span>
            </td>
        </tr>
    </table>
        
    @* Dynamic Loop Start*@
     foreach (var item in Model.listSummaryModel)
     {
     <table class="tblOrderSummarydynamic">
      <tr>
            <td width="55%">
                <b>@item.SubExtrasName</b>
                <br />
                <br />
                <b>@item.SubExtrasDetailName</b> <span class="fnt12left">plan</span>
                <br />
                <span class="fnt12left">on a</span> <b>@item.ExtraPlanQuotaValue @item.ExtraPlanQuotaInterval</b>
                <span class="fnt12left">contract</span>
            </td>
            <td width="15%">
                $@item.SubExtrasSetupFee
                <br />
                <span class="fnt12left">setup</span>
            </td>
            <td width="15%">
                $<span class="calculateMonthTotal">@item.SubExtrasDetailPrice</span>
                <br />
                <span class="fnt12left">per month</span>
            </td>
            <td width="15%">
                <span class="fnt12left">from</span>
                <br />
                <b>$</b><b class="calculateGrandTotal">@((item.ExtraPlanQuotaValue*item.SubExtrasDetailPrice) + item.SubExtrasSetupFee)</b>
                <br />
                <span class="fnt12left">over @item.ExtraPlanQuotaValue</span>
                <br />
                <span class="fnt12left">@item.ExtraPlanQuotaInterval</span>
            </td>
        </tr>
     </table>
     }
      @* Dynamic Loop End*@
        <br />
         @* Dynamic Loop Start*@
          foreach (var item in Model.listSummaryHardwareModel)
          {
               <table class="tblOrderSummarydynamicH">
      <tr>
      <td><b>@item.Quantity&nbsp;×&nbsp;@item.SubHardwareDetailName</b> ($@item.SubHardwareDetailPrice Each)<br />
          @item.SubHardwareDetail
      </td>
      <td width="19%"><center><b>$@(item.Quantity * item.SubHardwareDetailPrice)</b></center></td>
      </tr>
      </table>
          }
         @* Dynamic Loop End*@
        <br />
    <table class="tbl100" style="width:70%;">
        <tr>
            <td colspan="2" style="width:50%;">
                <b>&nbsp;Monthly price:&nbsp;<b>$<span id="spntotalMonth"></span></b> <span class="fnt12left">per month</span></b>
            </td>
            <td colspan="2" align="right"><b>&nbsp;Order Total:&nbsp;</b><b>$<span id="spntotalGrand"></span></b></td>
        </tr>
        
    </table>
    }
</div>
    <script type="text/javascript">
 $(function () {
     var calTotal = 0;
     var calTotalGrand = 0;
        //for each loop to calculate for the total monthy price.
        $(".calculateMonthTotal").each(function (index) {
            calTotal += parseFloat($(this).text());
            $("#spntotalMonth").text(calTotal);
        });

        $(".calculateGrandTotal").each(function (index) {
            calTotalGrand += parseFloat($(this).text());
            $("#spntotalGrand").text(calTotalGrand);
        });

    });
         </script>